<?php
//模块名_控制名
class Product_PickupController extends Zend_Controller_Action
{
	public function preDispatch(){
		$this->tplDirectory = "product/pickup/";
	}
	
	public function indexAction(){
		echo Cff::renderTpl($this->tplDirectory."index.tpl","layout");
	}
	
	public function listAction(){
		$page = $this->_request->getParam("page",1);
		$pageSize = $this->_request->getParam("pageSize",20);
		$op_code = trim($this->_request->getParam("pickupCode",""));
		$op_status=$this->_request->getParam("op_status",'');
		$orders_code=trim($this->_request->getParam("orders_code",''));
		$orderType=trim($this->_request->getParam("orderType",'0'));
		$return = array();
		$return['ask'] = 0;
		
		if(!empty($orders_code)){
			$mapInfo = Product_Service_OrderPickupMap::getByValue($orders_code,'orders_code');
			if (!empty($op_code) && $mapInfo){
				if($op_code != $mapInfo['op_code']){
					die(json_encode($return));
				}
			}elseif (empty($op_code) && $mapInfo) {
				$op_code = $mapInfo['op_code'];
			}
		}
		
		$conarr=array(
				"op_code"=>$op_code,
				"op_status"=>$op_status,
				"orderType"=>$orderType
				);
		$results = Product_Service_Pickup::getByCondition($conarr,"*",$page,$pageSize);
		$total = Product_Service_Pickup::getByCondition($conarr,"count(*)");
		$return['ask'] = 1;
		$return['total'] = $total;
		$return['results'] = $results;
		die(json_encode($return));
	}
	
	public function getDetailsAction(){
		$pickupCode = trim($this->_request->getParam("pickupCode",""));
		$condition = array(
			"op_code" => $pickupCode,
		);
		$opms = Product_Service_Pickup::getPickupMap($condition);
		$result = array("ask" => false);
		if(!empty($opms)){
			$result['ask'] = true;
			$result['opms'] = $opms;
		}
		die(json_encode($result));
	}
	
	/**
	*确认下架
	*/
	public function confirmPickupAction(){
		$pickupCode = trim($this->_request->getParam("pickupCode",""));
		$result =  array (
				'ask' =>0,
				'msg' => '下架确认功能已经与打包贴标功能合并'
		);
		
		$result = Product_Service_Pickup::confirmPickupTransaction($pickupCode);
		die(json_encode($result));
	}
}